const base_url = "https://api-hmugo-web.itheima.net"
export const myRequest = function(options) {
	return new Promise((resolve, reject) => {
		uni.showLoading({
			title: '加载中...'
		});
		uni.request({
			url:base_url + options.url,
			method:options.method || 'GET',
			data:options.data || {},
			success(res) {
				// console.log(res)
				if(res.data.meta.status != 200){
					uni.showToast({
						icon:'none',
					    title: res.data.meta.msg,
					    duration: 3000
					});
				}
				resolve(res)
				uni.hideLoading()
			},
			fail(err) {
				uni.hideLoading()
				uni.showToast({
					icon:'none',
				    title:'接口请求失败'
				});
				reject(err)
			},
			complete(e) {
				// console.log(e)
				uni.hideLoading()
			}
		})
	})
}
